package com.zookeeper.zkclient;

import org.I0Itec.zkclient.IZkDataListener;
import org.I0Itec.zkclient.ZkClient;

import java.util.List;
import java.util.concurrent.TimeUnit;

/**
 * Created with LXD
 *
 * @author:Luhui
 * @qq:729913162
 * @Date:2018-08-27
 * @Time:14:50
 */
public class SessionDemo {
    public static void main(String[] args) throws InterruptedException {
        ZkClient zkClient = new ZkClient("192.168.220.129:2181",4000);
        zkClient.subscribeDataChanges("/haha3", new IZkDataListener() {
            @Override
            public void handleDataChange(String s, Object o) throws Exception {
                System.out.println(s+"->"+o);
            }

            @Override
            public void handleDataDeleted(String s) throws Exception {

            }
        });
       zkClient.createEphemeral("/haha3");


        TimeUnit.SECONDS.sleep(4);
    }
}
